#!/bin/bash

# Copyright (c) 2022 FuTeng
# FuYao-RepoPackageTest-System is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#          http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.

# #################################################
# @Author    :   futeng
# @Contact   :   lanshaa123@163.com
# @Desc      :   扶摇docker版总脚本
# @Note      :   宿主机需要安装docker
# #################################################

source ./parameters/global-variable.sh
source ./parameters/functions.sh

# 检查身份证文件UUID是否存在
checkUUID

# 检查docker服务是否运行
checkDocker

case $1 in
	-ci )
		# 通过被测OS的ISO文件制作对应OS的docker镜像
		clear
		I_UUID=`cat $WORK_DIR/UUID`
		# 检查被测ISO是否存在
		checkISO $2
		createDockerImage $2
		;;
	-bi )
		clear
		baseInstall	$2
		;;
	-biu )
		clear
		baseIU $2
		;;
	-exi )
		clear
		exInstall $2 $3
		;;
	-exiu )
		clear
		exIU $2 $3	
		;;
	-degrade )
		# clear
		# checkDockerImage
		echo -e "\033[41;37m Repo package 【degrade】 test is about to be tested !!! \033[0m"
		echo -e "\033[41;37m 即将进行软件包降级测试！！ \033[0m"
		echo -e "\033[41;37m The function is temporarily unavailable. Stay tuned !!! \033[0m"
		echo -e "\033[41;37m 该功能暂时无法使用，敬请期待！！ \033[0m"
		exit 0
		;;
	-result )
		clear
		echo -e "\033[41;37m 查看测试进度 \033[0m"
		testStatusAll
		exit 0
		;;
	# -check )
	# 	# clear
	# 	echo -e "\033[41;37m Check machine \033[0m"
	# 	echo -e "\033[41;37m 检查宿主机 \033[0m"
	# 	echo -e "\033[41;37m The function is temporarily unavailable. Stay tuned !!! \033[0m"
	# 	echo -e "\033[41;37m 该功能暂时无法使用，敬请期待！！ \033[0m"
	# 	exit 0
	# 	;;
	-clean )
		# 清除之前的测试结果，慎用！！！
		# clear
		cleanTestResults
		exit 0
		;;
	-h )
		# 帮助提示信息
		clear
		help
		;;
	* )
		# 参数错误显示信息
		clear
		error
		;;
esac


